package demo1;

/**
 * @Author 12629
 * @Description：
 */
/* 不同名的成员变量
class Base {
    public int a;
    public int b;

}
class Derived extends Base {
    public int c;

    public void method() {
        a = 1;
        b = 2;
        c = 3;
    }
}
*/
/*class Base {
    public int a = 9;
    public int b = 99;

}
class Derived extends Base {
    public int a = 88;

    public void method() {
        //同名的情况下  优先看子类是否有当前成员变量
        System.out.println("a: "+a);
        System.out.println("b: "+b);
    }
}*/
class Base {
    int a = 99;
    public void method() {
        System.out.println("B::method()");
    }

}
class Derived extends Base {
    int a = 199;
    public void method2() {
        System.out.println("Derived::method()");
    }

    public void method() {
        System.out.println("Derived::method()");
    }

    public void test() {
        super.method();
        method2();
        System.out.println("===============");
        System.out.println(a);
        System.out.println(this.a);
        System.out.println(super.a);
    }
}
public class Test2 {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.test();
    }
}
